<!-- include tpl=head -->
<script type="text/javascript" src="{func add_js plugin.js}"></script>
<script type="text/javascript">
function create_plugin()
{
	$.dialog({
		'title':'{lang创建一个新的插件}',
		'width':'400px',
		'height':'220px',
		'lock':true,
		'content':document.getElementById('create_plugin_html'),
		'ok':function(){
			var url = get_url('plugin','create');
			var title = $("#plugin_name").val();
			if(!title){
				$.dialog.alert('插件名称不能为空');
				return false;
			}
			url += "&title="+$.str.encode(title);
			var id = $("#plugin_id").val();
			if(id){
				url += "&id="+$.str.encode(id);
			}
			var note = $("#plugin_note").val();
			if(note){
				url += "&note="+$.str.encode(note);
			}
			var author = $("#plugin_author").val();
			if(author){
				url += "&author="+$.str.encode(author);
			}
			var rs = $.phpok.json(url);
			if(rs.status == 'ok'){
				$.dialog.alert('插件创建成功，请根据实际情况编写插件扩展',function(){
					$.phpok.reload();
				},'succeed');
			}else{
				$.dialog.alert(rs.content);
				return false;
			}
		},
		'cancel':function(){
			return true
		}
	});
}
function plugin_zip(id)
{
	var url = get_url('plugin','zip','id='+id);
	$.phpok.go(url);
}
</script>
<div id="create_plugin_html" style="display:none">
	<div class="table">
		<div class="title">
			{lang插件名称}
			<span class="note">{lang设置插件的名称}</span>
		</div>
		<div class="content"><input type="text" id="plugin_name" class="default" /></div>
	</div>
	<div class="table">
		<div class="title">
			{lang插件标识}
			<span class="note">{lang限英文字母和数字，为空由系统生成32位长度字串}</span>
		</div>
		<div class="content"><input type="text" id="plugin_id" class="default" /></div>
	</div>
	<div class="table">
		<div class="title">
			{lang插件功能}
			<span class="note">{lang简单一句话描述这个插件做什么}</span>
		</div>
		<div class="content"><input type="text" id="plugin_note" class="default" /></div>
	</div>
	<div class="table">
		<div class="title">
			{lang开发者}
			<span class="note">{lang设置这个插件的开发人员或团队}</span>
		</div>
		<div class="content"><input type="text" id="plugin_author" class="default" /></div>
	</div>
</div>
<div class="tips">
	{lang您当前的位置：}<a href="{url ctrl=plugin/}">{lang插件列表}</a>
	&raquo; {lang已安装的插件}
	<div class="action"><a href="javascript:create_plugin();void(0);">{lang创建插件}</a></div>
	<div class="clear"></div>
</div>
<div class="list">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
	<th width="10px">&nbsp;</th>
	<th width="30px">{lang状态}</th>
	<th>{lang名称}</th>
	<th width="40px">{lang排序}</th>
	<th>&nbsp;</th>
</tr>
<!-- loop from=$rslist key=$key value=$value -->
<tr{if $rslist_id.num%2 == ""} class="list"{/if}>
	<td class="center">&nbsp;</td>
	<td>
		<span class="status{$value.status}" id="status_{$key}" onclick="phpok_status('{$key}','{func admin_url plugin status}')" value="{$value.status}"></span>
	</td>
	<td>{$value.title} <!-- if $value.note --><span class="gray i">（{$value.note}）</span><!-- /if --></td>
	<td class="center">{$value.taxis}</td>
	<td align="right">
		<input type="button" value="{lang卸载}" class="btn" onclick="plugin_uninstall('{$key}','{$value.title}')" />
		<input type="button" value="{lang配置}" class="btn" onclick="plugin_config('{$key}')" />
		<input type="button" value="{lang导出}" class="btn" onclick="plugin_zip('{$key}')" />
		<span id="node-action-{$key}"></span>
	</td>
</tr>
<!-- /loop -->
</table>
</div>
<input type="hidden" name="zipfile" id="zipfile" value="" />
<div class="tips">
	{lang未安装插件}
	<div class="action" style="background:none;margin:1px;padding-right:0;"><div id="zipfile_picker"></div></div>
</div>
<div class="_progress" id="zipfile_progress"></div>
<script type="text/javascript">
var obj_zipfile;
$(document).ready(function(){
	obj_zipfile = new $.admin_upload({
		'id':'zipfile',
		'swf':'{#js#}/webuploader/uploader.swf',
		'server':'{url ctrl=upload func=save cateid=1/}',
		'pick':{'id':'#zipfile_picker','multiple':false},
		'resize':false,
		'multiple':"false",
		"formData":{'{func session_name}':'{func session_id}'},
		'fileVal':'upfile',
		'disableGlobalDnd':true,
		'compress':false,
		'auto':true,
		'sendAsBinary':true,
		'accept':{'title':'压缩包(*.zip)','extensions':'zip'},
		'fileSingleSizeLimit':'204800000',
		'success':function(file,data){
			//执行在线解压
			var url = get_url('plugin','unzip','id='+data.content.id);
			var rs = $.phpok.json(url);
			if(rs.status == 'ok'){
				$.dialog.alert('插件导入成功，请执行安装',function(){
					$.phpok.reload();
				},'succeed');
			}else{
				$.dialog.alert(rs.content);
				return false;
			}
		}
	});
});
</script>
<div class="list">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
	<th width="10px">&nbsp;</th>
	<th>{lang名称}</th>
	<th></th>
</tr>
<!-- loop from=$not_install key=$key value=$value -->
<tr{if $not_install_id.num%2 == ""} class="list"{/if}>
	<td class="center">&nbsp;</td>
	<td>{$value.title} <!-- if $value.note || $value.desc --><span class="gray i">（{$value.note ? $value.note : $value.desc}）</span><!-- /if --></td>
	<td align="right"><input type="button" value="{lang安装}" class="btn" onclick="plugin_install('{$key}','{$value.title}')" /></td>
</tr>
<!-- /loop -->
</table>
</div>
<!-- include tpl=foot -->
